home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: miker3@ix.netcom.com (Mike Rubenstein)
- Newsgroups: comp.lang.c
- Subject: Re: fflush and Visual C++
- Date: Sun, 17 Mar 1996 16:14:23 GMT
- Organization: Netcom
- Message-ID: <314c38f1.145222809@nntp.ix.netcom.com>
- References: <4idhv5$dnv@news.mhv.net> <314b173b.71056173@nntp.ix.netcom.com> <4ig0cq$gkg@skivs.ski.org>
- NNTP-Posting-Host: ix-dc12-26.ix.netcom.com
- X-NETCOM-Date: Sun Mar 17 8:14:23 AM PST 1996
- X-Newsreader: Forte Agent .99d/32.182
-
- gt@ns.oon.or.jp (Gemini Thunder) wrote:
-
- > miker3@ix.netcom.com (Mike Rubenstein) wrote:
- >
- > >Vinny.Bedus@bbs.mhv.net (Vinny Bedus) wrote:
- >
- > >> Can someone please tell me why when fflush function is used in Visual C
- > >> under a dos box it doesn't work? I have no problems with turbo c for win
- > >> but anything else and it doesn't flush the stdin buffer.
- > >> any ans??????????????
- >
- > >Perhaps because Visual C implements fflush() correctly. fflush() does
- > >not flush input buffers. fflush() with stdin as an argument results
- > >in undefined behavior.
- >
- > >Michael M Rubenstein
- >
- > Could you explain why fflush(stdin) results in undefined behavior?
- > I have been using this construct, (apparently) unaware of this.
-
- Because the standard does not define what fflush(stdin) does. From
- ISO 7.9.5.2:
-
- If stream points to an output stream or an update stream in
- which the most recent operation was not input, the fflush
- function causes any unwritten data for that stream to be
- delivered to the host environment to be written to the file;
- otherwise, the behavior is undefined.
-
- I'd suggest you stick to using fflush() for its intended purpose --
- flushing output streams.
-
-
-
- Michael M Rubenstein
-